/**
 * Created by Ru on 14/12/16.
 */
var myApp = angular.module('myApp',['ngCookies']);


// myApp.value('test','testvalue')

myApp.controller('editController',['$scope','$http','$location','$interval','$window','$cookieStore',function ($scope,$http,$location,$interval,$window,$cookieStore) {
    console.log('editController loaded');


    $scope.getFault = function () {
        // console.log(sss)
        var id = $cookieStore.get("editFaultId")
        $http.get('../api/faults/' + id).success(function (response) {
            $scope.fault = response;
            console.log($scope.fault);
        });

    };



    $scope.updateFault = function () {
        var id = $cookieStore.get("editFaultId");
        console.log(id);
        $http.put('../api/faults/'+id,$scope.fault).success(function (response) {

            alert("更新成功!");
            window.location.href='projects.html';
        });

        // $http.put('../api/faults/' + )
    };

    // $scope.updateFault = function () {
        //     var id = $routeParams.id;
        //     $scope.fault.imageName = $scope.imageName;
        //
        //     $http.put('api/faults/'+id,$scope.fault).success(function (response) {
        //         window.location.href='#/faults';
        //     });
        // }










}]);
